﻿<!DOCTYPE html>
<html>

<head>
    <title>DAENET - GeoLocation Sample</title>
    <script type="text/javascript">

        function getPosition(position) {
            try {
                navigator.geolocation.getCurrentPosition(showPosition, onGeoError);
                m_TxtCoordinate.value = "getLocation called";
            }
            catch (err) {
                m_TxtCoordinate.value = err;
            }
        }

        function onGeoError(error) {
            m_TxtCoordinate.value = error;
        }

        function showPosition(location) {

            try {
                m_TxtCoordinate.value = "show position called";
                m_TxtCoordinate.value = "Long:" + location.coords.longitude + ", lat:" + location.coords.latitude;
            }
            catch (err) {
                m_TxtCoordinate.value = err;
            }
        }


        var watchId;

        function startWatching() {

            var txt = document.getElementById("m_TxtCoordinate");
            txt.value = "";
            watchId = navigator.geolocation.watchPosition(showPosition);
        }

        function stopWatching() {

            var txt = document.getElementById("m_TxtCoordinate");
            txt.value = "";
            navigator.geolocation.clearWatch(watchId);
        }

        
    </script>
    <style type="text/css">
        #m_TxtCoordinate
        {
            width: 258px;
        }
    </style>
</head>
<body>
    Click to get geo coordinate:<br />
    <button style="width: 100px; height: 35px" type="button" onclick="getPosition();">
    </button>
    <br />
    Click to start watching:<br />
    <button style="width: 100px; height: 35px" type="button" onclick="startWatching();">
    </button>
    <br />
    Click to stop watching:<br />
    <button style="width: 100px; height: 35px" type="button" onclick="stopWatching();">
    </button>
    <br />
    <br />
    <br />
    <input type="text" id="m_TxtCoordinate" />
</body>
</html>
